$(function(){

	//登录窗的tab切换
	$(document).on("click",".login-form>ul>li",function(){
		$(this).closest("ul").find("li").removeClass("active");
		$(this).addClass("active");
	})
	
	/*登录验证*/
    $(".login-form").on("click","#loginBtn",function(){
        var account = $('[name="account"]').val(),
            password = $('[name="password"]').val(),
            wrongTip = $(".login-btn").find(".error-tip");

        if (account.replace(/\s/g,"")==="") {
            wrongTip.text("账号不能为空！");
        }
        // else if (!/^\w{3,8}$/.test(account)){
        //     wrongTip.text("账号格式不正确！");
        // }
        else if (password.replace(/\s/g,"")==="") {
            wrongTip.text("密码不能为空！");
        }
        else{
            wrongTip.text("");
            location='page/homePage.html';
        }
    })


    /*修改密码*/
	$(document).on("click",".tip-btn",function(){
        var $this = $(this),
            tipStyle = $this.attr("tip"),
            btnid = $this.attr("id"),
            oldPsw = $('[name="oldPsw"]').val(),
            newPsw = $('[name="newPsw"]').val(),
            rePsw = $('[name="rePsw"]').val();

        /*显示成功弹窗*/  
        if (tipStyle=="success" && checkWTip(this)){
        	if ($this.hasClass("save-psw")) {
                //todo 二级判断，判断原密码是否正确等
                if (rePsw != newPsw) {
                    addWTip($('[name="rePsw"]'),"与新密码不一致！");
                    return
                }
                
        		addTipHtml(
	                "success", 
	                "密码修改成功！",
	                "",
	                "确定",
	                "green",
	                function(){
	                    closeWindow();
                        window.history.go(0);
	                }
	            );
        	}
        }
    });
    
})
